package com.gzhryc.shared_device.common.device.dao.db;

import com.gzhryc.jdbc.annotaion.Column;
import com.gzhryc.jdbc.annotaion.Id;
import com.gzhryc.jdbc.annotaion.Join;
import com.gzhryc.jdbc.annotaion.Table;
import com.gzhryc.shared_device.common.device.dao.enums.DeviceProduceBatchEnum;

import java.io.Serializable;
import java.util.Date;

/**
 * 设备生产批次，默认一个批次最多9999个设备，排除四位数重复
 * 批次ID的生成，设备类型+四位数，当四位数重复时，其中第二数用字母代替，当四位数超过9999从第一位从字母表开始，字母"o","v,"I","Q"除外
 * @version 2022-10-09
 */
@Table(name="device_produce_batch")
public class DeviceProduceBatch implements Serializable {

    private static final long serialVersionUID = 1L;

	@Id(auto = false)
    @Column(name="batch_id",notNull = true,note = "批次ID(序列号前缀)")
    protected String batchId;

    @Column(notNull = true,note = "批次名称")
    protected String name;

    @Column(name = "device_type_id",notNull = true,note = "设备类型")
    protected String deviceTypeId;

    @Column(name = "start_num",notNull = true,defVal = "1",note = "生产的数量")
    protected Integer startNum;

    @Column(name = "produce_total",notNull = true,defVal = "1",note = "生产的数量")
    protected Integer produceTotal;

    @Column(name = "config_content",type = "TEXT",note = "设备配置内容")
    protected String configContent;

    @Column(notNull = true,defVal = "1",note = "状态")
    protected Integer state;

    @Column(name = "update_date", autoUpdateTime = true, note = "最后修改时间")
    protected Date updateDate;

    @Column(name = "create_date")
    protected Date createDate;

    @Join(fromField = "device_type_id")
    protected DeviceType deviceType;

    public String getBatchId() {
        return batchId;
    }

    public void setBatchId(String batchId) {
        this.batchId = batchId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDeviceTypeId() {
        return deviceTypeId;
    }

    public void setDeviceTypeId(String deviceTypeId) {
        this.deviceTypeId = deviceTypeId;
    }

    public Integer getStartNum() {
        return startNum;
    }

    public void setStartNum(Integer startNum) {
        this.startNum = startNum;
    }

    public Integer getProduceTotal() {
        return produceTotal;
    }

    public void setProduceTotal(Integer produceTotal) {
        this.produceTotal = produceTotal;
    }

    public String getConfigContent() {
        return configContent;
    }

    public void setConfigContent(String configContent) {
        this.configContent = configContent;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public DeviceType getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(DeviceType deviceType) {
        this.deviceType = deviceType;
    }

    public String getStateName(){
        return DeviceProduceBatchEnum.State.note(this.state);
    }
}
